libxl/gentypes.py: don't generate default values
authorWei Liu <wei.liu2@citrix.com>
Wed, 9 Jul 2014 09:45:24 +0000 (10:45 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 10 Jul 2014 12:06:55 +0000 (13:06 +0100)
commit731233d64f6a7602c1ca297f7b67ec25433642e7
tree910c61e29b7a319797f588cc4d504aa353898087
parent47925f378394cd1351b4f1992bd75bed7e3ace93
libxl/gentypes.py: don't generate default values

If a field:
    0. is not of aggregate type
and
    1. is of array type and the array is not empty
or  2. is of a type which has init_val and has been set to init_val,
or  3. is of builtin type and has been set to internal default value,
or  4. is of a type which has no init_val and has been set to 0

then there's no need to generate output for that field in JSON
output.

Note that 0 can result in output like
  {
    ...
    FOO : { }
    ...
  }
where FOO is aggregate type but all its fields are set to default, hence
no JSON output in {} at all. This is not pretty, but it's still valid
JSON. And the parser should be able to skip touching those fields in the
resulting C structures. When the parser consumes that generated JSON
object, all default values should be automatically filled in.

Also change some non-zero init_vals to LIBXL_* for better readability in
generated C code.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/gentypes.py
tools/libxl/idl.py
tools/libxl/idl.txt
tools/libxl/libxl_types.idl